<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Promotional_model extends MY_Model
{
    public function __construct() {
        parent::__construct();
    }
	/**
	 * 获取列表
	 *
	 * return array
	 */
	public function getPromotionalList($data, $per_page, $limit, $filds="*"){
       $where = " ";
        
        if(!empty($data['keyword'])){
            $where .= " AND content like '%{$data['keyword']}%' OR title like '%{$data['keyword']}%' OR transferfrom like '%{$data['keyword']}%'";
        }
       
        if($data['region'] != 0){
            $where .= " AND (region like '%{$data['region']}%' OR region ='' OR region is null )";
        }
    	if($per_page){
            	$per_page = ($per_page-1)*$limit;
    	}	
        $limit = " limit {$per_page},{$limit}";

        $sql = "SELECT {$filds} FROM blues_promotional WHERE isDel<>1 and onlinestatus=1  {$where} order by publishtime desc {$limit} ";

        $query = $this->db->query($sql);
        $result =$query->result_array();
        return $result;
    }

    //获取动态说说详情
    public function getPromotionalDetail($id,$filds = "*"){
        $sql = "SELECT 
                    {$filds} 
                FROM 
                    blues_promotional  
                WHERE 
                    id={$id} 
                AND 
                    isDel = 0 ";
        $query = $this->db->query($sql);
        $result =$query->row_array();
        
        return $result;
    }
}

